{extend name="Public:content"}
{block name="content"}
<form class="form-horizontal m-t" id="addUserFrom"  method="post" action="{:url('admin/user/add')}">
    <div class="form-group">
        <label class="col-sm-2 control-label">用户账号：</label>
        <div class="col-sm-8">
            {if $vo and isset($vo.username)}
            <input readonly="readonly" disabled="disabled" name="username" value='{$vo.username|default=""}' required="required" title="请输入用户名称" placeholder="请输入用户名称" class="form-control">
            {else}
            <input name="username" value='{$vo.username|default=""}' required="required" pattern="^.{4,}$" title="请输入用户名称" placeholder="请输入4位及以上字符用户名称" class="form-control">
            {/if}
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">联系手机：</label>
        <div class="col-sm-8">
            <input type="tel" autofocus name="phone" value='{$vo.phone|default=""}' pattern="^1[3-9][0-9]{9}$" title="请输入联系手机" placeholder="请输入联系手机" class="form-control">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">联系邮箱：</label>
        <div class="col-sm-8">
            <input name="mail" pattern="^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$" value='{$vo.mail|default=""}' title="请输入联系邮箱" placeholder="请输入联系邮箱" class="form-control">
        </div>
    </div>
    {if isset($authorizes)}
    <div class="form-group">
        <label class="col-sm-2 control-label">访问授权：</label>
        <div class="col-sm-8">
            <div class="checkbox i-checks">
                {volist name="authorizes" id="authorize"}
                {if in_array($authorize['id'],$vo['authorize'])}
                <label {eq name="i" value="1"}style="padding-left:0"{/eq}><input type="checkbox"  value="{$authorize.id}" name="authorize[]" checked> <i></i> {$authorize.title}</label>
                {else}
                <label {eq name="i" value="1"}style="padding-left:0"{/eq}><input type="checkbox"  value="{$authorize.id}" name="authorize[]"> <i></i> {$authorize.title}</label>
                {/if}
                {/volist}
                {if empty($authorizes)}
                <span class="color-desc" style="line-height:36px">未配置权限</span>
                {/if}
            </div>
        </div>
    </div>
    {/if}
    <div class="form-group">
        <label class="col-sm-2 control-label">用户描述：</label>
        <div class="col-sm-8">
            <textarea placeholder="请输入用户描述" title="请输入用户描述" class="form-control" name="desc">{$vo.desc|default=""}</textarea>
        </div>
    </div>
    <div class="hr-line-dashed"></div>
    <div class="form-group">
        <div class="col-sm-12 text-center">
            {if isset($vo['id'])}<input type='hidden' value='{$vo.id}' name='id'/>{/if}
            <button class="btn btn-primary" type="submit">保存数据</button>
            <button class="btn btn-primary btn-danger" type='button' data-confirm="确定要取消编辑吗？" onclick="$.Oa.confirm(this)">取消编辑</button>
        </div>
    </div>
</form>
{/block}
{block name="script"}
<script type="text/javascript">
    //表单提交
    $('#addUserFrom').validate({
        submitHandler: function(form) {
            $.Oa.doHform('#addUserFrom',false,false,function(data){
                parent.layer.msg(data.msg);
                var iframe ='{$iframe}';
                var n = parent.$("iframe[name='"+iframe+"']").index();
                parent[n].location.reload();
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);
            })
        }
    })
</script>
{/block}

